import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'
import operation from './modules/operation'
import hosts from './modules/hosts'
import news from './modules/news'
import warnmanage from './modules/warnmanage'
import usermanage from './modules/usermanage'
import person from './modules/person'
import developdoc from './modules/developdoc'
import digitalTwin from'./modules/digitalTwin'

/**
 * 静态路由
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true // 隐藏
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '监控概览', icon: 'dashboard' }
    }]
  },
  {
    path: '/analysis',
    name: 'Tree',
    component: () => import('@/views/analysis/index'),
    meta: { title: '智能数据处理', icon: 'message1' }
  },
  {
    path: '/chat',
    component: Layout,
    children: [{
      path: 'chat',
      name: 'chat',
      component: () => import('@/views/chat/index'),
      meta: { title: '智能运维', icon: 'message1' }
    }]
  }
  // {
  //   path: '/analysispage',
  //   component: Layout,
  //   children: [{
  //     path: 'dashboard',
  //     name: 'Dashboard',
  //     component: () => import('@/views/analysisPage/index'),
  //     meta: { title: '数据分析', icon: 'message1' }

  //   }]
  // }
  // 运维管理
  // operation,
  // 报警通知
  // message,
  // 个人管理
  // person,
  // 开发文档
  // 404 page must be placed at the end !!!
  // { path: '*', redirect: '/404', hidden: true }
]

/**
 * 动态路由
 */
export const asyncRouter = [
  digitalTwin,
  hosts, // 主机概览
  operation, // 运维管理
  warnmanage, // 报警通知
  news, // 公告通知
  usermanage, // 用户管理
  person, // 个人信息
  developdoc, // 开发文档
  
]

const createRouter = () => new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
